cmake_minimum_required(VERSION 3.5)
project(msg_convert)

set(ua_vision_MAJOR_VERSION 0)
set(ua_vision_MINOR_VERSION 0)
set(ua_vision_PATCH_VERSION 1)
set(ua_vision_VERSION
  ${ua_vision_MAJOR_VERSION}.${ua_vision_MINOR_VERSION}.${ua_vision_PATCH_VERSION}
)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/cmake")

SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3 -Wall -g")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -fPIC ${COMPILER_WARNINGS} -pthread")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O3")


set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMPILER_WARNINGS} -pthread")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O3")


if (NOT CMAKE_BUILD_TYPE)
  # if build type is not specific, setting default type to Release
  set(CMAKE_BUILD_TYPE Release)
endif()
message(STATUS "Project build type : ${CMAKE_BUILD_TYPE}")

set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} CACHE PATH "Project output library path")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin CACHE PATH "Project output binary path")

find_package(catkin REQUIRED COMPONENTS
 roscpp
 rospy
 std_msgs
 sensor_msgs
#  pcl_conversions
#  pcl_msgs
#  pcl_ros
#  cv_bridge
#  image_transport
 zhz_msgs
 camera_info_manager
)

catkin_package(CATKIN_DEPENDS
roscpp
)

# Find Packages
# OpenCV
find_package(OpenCV REQUIRED)
if (OpenCV_FOUND)
    message(STATUS "OpenCV is found, version " ${OpenCV_VERSION})
else()
    message(WARNING "Failed to find OpenCV")
endif()


include_directories(
  ${PROJECT_SOURCE_DIR}/sdk/include
  ${OpenCV_INCLUDE_DIRS}
  ${catkin_INCLUDE_DIRS}
  # ${zhz_msgs_INCLUDE_DIRS}
  # ${PCL_DEFINITIONS} 
  )

  
  
  # x86数据测试
if (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
  add_definitions(-DAARCH64)
  add_executable(${PROJECT_NAME} demo/msg_convert.cpp)
  target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES})  
  # 交叉编译
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
  add_definitions(-DX86_64)
  file(GLOB NX_Driver_LIBS LIST_DIRECTORIES true  ${PROJECT_SOURCE_DIR}/sdk/lib/*.so)
  add_executable(pub_gps demo/pub_gps.cpp)
  target_link_libraries(pub_gps ${catkin_LIBRARIES} ${NX_Driver_LIBS})  
  
  add_executable(pub_img demo/pub_img.cpp)
  target_link_libraries(pub_img ${catkin_LIBRARIES} ${NX_Driver_LIBS})  
  
  add_executable(pub_imu demo/pub_imu.cpp)
  target_link_libraries(pub_imu ${catkin_LIBRARIES} ${NX_Driver_LIBS})  
  
  add_executable(vision_demo demo/main.cpp)
  target_link_libraries(vision_demo ${NX_Driver_LIBS} ${OpenCV_LIBS}) 
  
  add_executable(${PROJECT_NAME}_arm demo/msg_convert_arm.cpp)
  target_link_libraries(${PROJECT_NAME}_arm ${catkin_LIBRARIES} ${NX_Driver_LIBS})  
endif()

